package com.hualan.sfzy.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hualan.sfzy.constant.CommonConstant;
import com.hualan.sfzy.mapper.ConsultReservationMapper;
import com.hualan.sfzy.model.dto.ConsultReservationDto;
import com.hualan.sfzy.model.entity.CharityCenter;
import com.hualan.sfzy.model.entity.ConsultReservation;

import com.hualan.sfzy.model.vo.ConsultReservationQuery;
import com.hualan.sfzy.service.ConsultReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 咨询预约服务实现类
 */
@Service
public class ConsultReservationServiceImpl implements ConsultReservationService {
    @Autowired
    private ConsultReservationMapper consultReservationMapper;

    @Override
    public int add(ConsultReservation entity) {
        return consultReservationMapper.insert(entity);
    }

    @Override
    public int edit(ConsultReservation entity) {
        return consultReservationMapper.update(entity);
    }

    @Override
    public int remove(Integer id) {
        return consultReservationMapper.delete(id);
    }

    @Override
    public int removeBatch(Integer[] ids) {
        return consultReservationMapper.deleteBatch(ids);
    }

    @Override
    public List<ConsultReservation> find() {
        return consultReservationMapper.select(new ConsultReservation());
    }

    @Override
    public Map<String, Object> findReservationPage(Integer pageNum, Integer pageSize, ConsultReservationQuery entity) {
        PageHelper.startPage(pageNum, pageSize);
        List<ConsultReservationDto> list = consultReservationMapper.select(entity);
        PageInfo<ConsultReservationDto> pageInfo = new PageInfo<>(list);
        Map<String, Object> pageMap = new HashMap<>();
        pageMap.put(CommonConstant.PAGE_LIST, list);
        pageMap.put(CommonConstant.PAGE_TOTAL, pageInfo.getPages());
        pageMap.put(CommonConstant.TOTAL, pageInfo.getTotal());
        return pageMap;
    }
    @Override
    public Map<String, Object> findPage(Integer pageNum, Integer pageSize, ConsultReservation entity) {
        throw new UnsupportedOperationException("此方法不支持，请使用findArticlePage");
    }

    @Override
    public ConsultReservation findById(Integer id) {
        return consultReservationMapper.selectById(id);
    }
    
    @Override
    public List<ConsultReservationDto> findAll() {
        return consultReservationMapper.selectAll();
    }
}